<template>
  <div class="header topbar">
    <div class="inner clearfix">
      <div class="lf" @click="goback"><i class="icon i-arr-l"></i></div>
      <slot name="rt" v-if="!hideShare">
        <div class="rt" @click="share"><i class="icon i-share"></i></div>
      </slot>
      <slot name="mid">
        <div class="mid only-row">{{headline}}</div>
      </slot>
    </div>
  </div>
</template>

<script>
//   import {isIOS} from '../utils/utils'
  
  export default {
    props: {
      headline: {type: String, default: ''},
      hideShare: {type: Boolean, default: false},
      jump: {type: String, default: ''}
    },
    methods: {
      goback: function () {
        if (window.history.length === 1) {
          this.$router.push('/home')
        } else {
          // 如果包含ISIOS表示在苹果微信端已经刷新过页面了
          if (window.location.href.includes('ISIOS')) {
            // this.$router.go(-2);
          } else {
            if (this.jump) {
              this.$router.push(this.jump)
            } else {
              this.$router.go(-1);
            }
          }
        }
      },
      share: function () {
        this.$emit('openShare');
      }
    }
  }
</script>

<style lang="less">
//   @import "../assets/less/topbar.less";
</style>
